package sedev.shopping.business;

import sedev.shopping.data.DonViGiaDAO;
import sedev.shopping.entities.DonViGia;
import sedev.shopping.entities.ListDonViGia;
import sedev.shopping.util.Paging;
import sedev.shopping.util.SedevUtil;

public class DonViGiaService {
	public static boolean addData(DonViGia data){
		DonViGiaDAO dao = new DonViGiaDAO();
		return dao.addData(data);
	}
	
	public static boolean updateData(DonViGia data){
		DonViGiaDAO dao = new DonViGiaDAO();
		return dao.updateData(data);
	}
	
	public static boolean removeData(int id){
		DonViGiaDAO dao = new DonViGiaDAO();
		return dao.removeData(id);
	}
	
	public static DonViGia getData(int id){
		DonViGiaDAO dao = new DonViGiaDAO();
		return dao.getData(id);		
	}
	
	public static ListDonViGia getListDataByAll(){
		StringBuilder field = new StringBuilder();
		field.append(DonViGia.Properties.id.name());
		field.append(",").append(DonViGia.Properties.ten.name());
		
		StringBuilder condition = new StringBuilder();
		condition.append("1 AND 1");
		
		StringBuilder order = new StringBuilder();
		order.append(DonViGia.Properties.id.name()).append(" ").append(
				SedevUtil.Order.DESC.name());
		Paging paging = new Paging();
		
		DonViGiaDAO dao = new DonViGiaDAO();
		return dao.getListData(field.toString(), condition.toString(), order.toString(), paging);
	}
}
